package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.enums.bi.DataSetNodeTypeEnum;
import lombok.Getter;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 筛选方式枚举类
 * @author zhouwq
 * @date 2019/4/4 16:10
 */

@Getter
public enum ScreenTypeEnum {
    /**
     * 筛选方式
     */

    SCREEN_OFF(0, "enum.screenType.describe.screen_off"),

    SCREEN_SHOW(1, "enum.screenType.describe.screen_show"),

    SCREEN_SEARCH(2, "enum.screenType.describe.screen_search"),

    SCREEN_GROUP(3, "enum.screenType.describe.screen_group"),

    SCREEN_RELATION(4, "enum.screenType.describe.screen_relation"),

    ;

    ScreenTypeEnum(Integer type, String describe){
        this.type = type;
        this.describe = describe;
    }

    private Integer type;

    private String describe;

    public String getDescribe() {
        return I18nMessageUtil.getMessage(describe);
    }

    /**
     * 数据集画布内各种场景允许操作的字段screeType集合
     * @return java.util.Map<java.lang.String,java.util.List<java.lang.Integer>>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public static Map<String, List<Integer>> dataSetScreenTypeAble(){
        Map<String, List<Integer>> screenTypeAble = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        //过滤条件：可以作为筛选的字段screeType 参考方法：ChartAttrHelp#filterSelectList - bi内要过滤的字段
        screenTypeAble.put("select", Arrays.asList(SCREEN_SEARCH.type, SCREEN_GROUP.type, SCREEN_RELATION.type));
        //合并节点：可合并字段screeType
        screenTypeAble.put(DataSetNodeTypeEnum.UNION.getAlias(), Arrays.asList(SCREEN_SHOW.type, SCREEN_SEARCH.type, SCREEN_GROUP.type, SCREEN_RELATION.type));
        //连接节点：可以作为连接的字段screeType 参考方法：ChartAttrHelp#filterGroupList - bi内要过滤的字段
        screenTypeAble.put(DataSetNodeTypeEnum.JOIN.getAlias(), Arrays.asList(SCREEN_GROUP.type, SCREEN_RELATION.type));
        //分组节点：可以作为分组的字段screeType 参考方法：ChartAttrHelp#filterGroupList - bi内要过滤的字段
        screenTypeAble.put(DataSetNodeTypeEnum.GROUP.getAlias(), Arrays.asList(SCREEN_GROUP.type, SCREEN_RELATION.type));
        return screenTypeAble;
    }
}
